import Mock from 'mockjs'

/**
 * 分页获取列表
 * 备注：member_user表 查询所有有上级邀请人的用户信息
 */
export const getRelationPage = async (
  params: pagination & SaleRelation
): Promise<ListSaleRelationRes> => {
  const res = await Mock.mock({
    'list|10': [
      {
        'id|+1': 1,
        nickName: '@cname',
        avatar: '@image(200x200)',
        name: '@cname',
        phone: '@integer(13000000000, 18999999999)',
        inviterNickName: '@cname',
        inviterAvatar: '@image(200x200)',
        inviterName: '@cname',
        inviterPhone: '@integer(13000000000, 18999999999)',
        createTime: 1691143890537,
        clientUserId: '@integer(13000000000, 18999999999)'
      }
    ],
    pageNo: 1,
    pageSize: 10,
    total: 30
  })
  return res
}

/**
 * 获取用户详情
 */
export const getRelation = async (userId: number): Promise<SaleRelation> => {
  const res = await Mock.mock({
    data: {
      'id|+1': 1,
      nickName: '@cname',
      avatar: '@image(200x200)',
      name: '@cname',
      phone: '@integer(13000000000, 18999999999)',
      inviterNickName: '@cname',
      inviterAvatar: '@image(200x200)',
      inviterName: '@cname',
      inviterPhone: '@integer(13000000000, 18999999999)',
      createTime: 1691143890537,
      clientUserId: '@integer(13000000000, 18999999999)'
    }
  })
  return res
}

/**
 * 更新用户信息
 */
export const updateRelation = async (params: SaleRelation): Promise<ResStatus> => {
  const res = await Mock.mock({
    isSuccess: true
  })
  return res
}

/**
 * 删除用户信息
 */
export const deleteRelation = async (userId: number): Promise<ResStatus> => {
  const res = await Mock.mock({
    isSuccess: true
  })
  return res
}
